import java.util.*;
public class MoveZerosACM {
    public void moveZeros(int[] nums){
        int left = 0,right = 0;
        while(right<nums.length){
            if(nums[right] != 0){
                swap(nums,left, right);
                left++;
            }
            right++;
        }
    }
    //交互数组中索引位置
    public void swap(int[] nums,int left,int right){
        int temp = nums[left];
        nums[left] = nums[right];
        nums[right] = temp;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] nums = new int[n];
        for (int i = 0;i < n; i++){
            nums[i] = scanner.nextInt();
        }
        MoveZerosACM solver = new MoveZerosACM();
        solver.moveZeros(nums);

        for(int num : nums){
            System.out.println(num + " ");
        }

        scanner.close();
    }

}
